/*
 * Copyright 2004-2005 asoft
 * 本软件及其所有拷贝的名称，与光盘上或本软件中注明的公司同在。
 * 本软件及文档享有版权，并受国家版权法及国际协约条款的保护。
 * 您不可以从本软件中去掉其版权声明；并保证为本软件的拷贝（本部或部分）* 复制版权声明。
 * 您同意制止以任何形式非法拷贝本软件及文档。
 * 版权信息参见：
 *      http://www.asoft.cn/licenses
 */

package com.asoft.examonline.exammanager.service;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;

import com.asoft.common.base.web.service.AbstractListService;
import com.asoft.examonline.exammanager.manager.ExamQuestionManager;
import com.asoft.examonline.exammanager.view.foreveryone.ExamQuestionList4EveryOne;

/**
 * <p>Title: 试题</p>
 * <p>Description: 查询试题</p>
 * <p>Copyright: Copyright (c) 2003</p>
 * <p>Company: asoft</p>
 * @ $Author: amon.lei $
 * @ $Date: 2005/02/16 01:04:15 $
 * @ $Revision: 1.6 $
 * @ created in 2007-2-20
 *
 */

public class FindExamQuestionsService extends AbstractListService
{
        static Logger logger = Logger.getLogger(FindExamQuestionsService.class);

        private ExamQuestionManager examQuestionManager;

        public void setExamQuestionManager(ExamQuestionManager examQuestionManager)
        {
                this.examQuestionManager = examQuestionManager;
        }

        /** 获取列表的models */
        public List getList(HttpServletRequest request)
        {
                // 获取翻页结果集合
                logger.debug("1. 获取查询条件.....");
                // 获取查询条件
                String domainId = this.getValueFromRequestParameter(request,"domainId");
                String subjectId = this.getValueFromRequestParameter(request,"subjectId");
                String courseId = this.getValueFromRequestParameter(request,"courseId");
                String sectionId = this.getValueFromRequestParameter(request,"sectionId");
                String unitId = this.getValueFromRequestParameter(request,"unitId");
                String knowledgePointId = this.getValueFromRequestParameter(request,"knowledgePointId");
                String knowledgeTypeId = this.getValueFromRequestParameter(request,"knowledgeTypeId");
                String questTypeId = this.getValueFromRequestParameter(request,"questTypeId");
                String difficultyId = this.getValueFromRequestParameter(request,"difficultyId");
                String sourceId = this.getValueFromRequestParameter(request,"sourceId");
                String authorName = this.getValueFromRequestParameter(request,"authorName");
                String content = this.getValueFromRequestParameter(request,"content");
                // 排序
                String orderBy = this.getValueFromRequestParameter(request,"orderBy","eq.lastUpdateTime");
                String sortType = this.getValueFromRequestParameter(request,"sortType","desc");
                logger.debug("2. 获取查询条件完毕,开始查询.....");
                return this.examQuestionManager.findExamQuestions(domainId,
                                                                   subjectId,
                                                                   courseId,
                                                                   unitId,
                                                                   sectionId,
                                                                   knowledgePointId,
                                                                   knowledgeTypeId,
                                                                   questTypeId,
                                                                   difficultyId,
                                                                   sourceId,
                                                                   authorName,
                                                                   content,
                                                                   orderBy,
                                                                   sortType);
        }

        /** model -> viewer */
        public Object getViewer(HttpServletRequest request)
        {
                // 根据request里面提供的参数做角色、权限判断,然后返回对应的viewer
                return new ExamQuestionList4EveryOne(); // foreveryone
        }
}
